package com.mycinema.biz.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.mycinema.biz.CategoryBiz;
import com.mycinema.dao.CategoryDao;
import com.mycinema.entity.Category;

@Service("categoryBiz")
//@Transactional(propagation=Propagation.REQUIRED)//整个方法启用事务
public class CategoryBizImpl implements CategoryBiz {
	
	@Autowired
	private CategoryDao categoryDao;
	
	//单个方法启用事务
	@Transactional(propagation=Propagation.REQUIRED)
	public List<Category> getAll() {
		
		return categoryDao.getAll();
	}

	public boolean add(Category category) {
		// TODO Auto-generated method stub
		return categoryDao.add(category);
	}

	public void delete(int id) {
		categoryDao.delete(id);
	}

	public boolean update(int id) {
		// TODO Auto-generated method stub
		return categoryDao.update(id);
	}
	
	@Transactional(readOnly=true)//不启用事务
	public Category getById(int id) {
		// TODO Auto-generated method stub
		return categoryDao.getById(id);
	}

	public List<Category> getWithList() {
		// TODO Auto-generated method stub
		return categoryDao.getWithList();
	}

	public List<Category> getCategoryMovies() {
		// TODO Auto-generated method stub
		return categoryDao.getCategoryMovies();
	}

}
